{{>header}}

{{#equals @root.httpClient 'angular'}}
{{#if @root.exportClient}}
import { Injectable } from '@angular/core';
import type { Observable } from 'rxjs';
{{else}}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import type { Observable } from 'rxjs';
{{/if}}

{{/equals}}
{{#if imports}}
{{#each imports}}
import type { {{{this}}} } from '../models/{{{this}}}';
{{/each}}

{{/if}}
{{#notEquals @root.httpClient 'angular'}}
import type { CancelablePromise } from '../core/CancelablePromise';
{{/notEquals}}
{{#if @root.exportClient}}
{{#equals @root.httpClient 'angular'}}
import { BaseHttpRequest } from '../core/BaseHttpRequest';
{{else}}
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
{{/equals}}
{{else}}
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
{{/if}}

{{#equals @root.httpClient 'angular'}}
@Injectable({
  providedIn: 'root',
})
{{/equals}}
export class {{{name}}}{{{@root.postfix}}} {
	{{#if @root.exportClient}}

	constructor(public readonly httpRequest: BaseHttpRequest) {}
	{{else}}
	{{#equals @root.httpClient 'angular'}}

	constructor(public readonly http: HttpClient) {}
	{{/equals}}
	{{/if}}

	{{#each operations}}
	/**
	{{#if deprecated}}
	 * @deprecated
	{{/if}}
	{{#if summary}}
	 * {{{escapeComment summary}}}
	{{/if}}
	{{#if description}}
	 * {{{escapeComment description}}}
	{{/if}}
	{{#unless @root.useOptions}}
	{{#if parameters}}
	{{#each parameters}}
	 * @param {{{name}}} {{#if description}}{{{escapeComment description}}}{{/if}}
	{{/each}}
	{{/if}}
	{{/unless}}
	{{#each results}}
	 * @returns {{{type}}} {{#if description}}{{{escapeComment description}}}{{/if}}
	{{/each}}
	 * @throws ApiError
	 */
	{{#if @root.exportClient}}
	{{#equals @root.httpClient 'angular'}}
	public {{{name}}}({{>parameters}}): Observable<{{>result}}> {
		return this.httpRequest.request({
	{{else}}
	public {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> {
		return this.httpRequest.request({
	{{/equals}}
	{{else}}
	{{#equals @root.httpClient 'angular'}}
	public {{{name}}}({{>parameters}}): Observable<{{>result}}> {
		return __request(OpenAPI, this.http, {
	{{else}}
	public static {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> {
		return __request(OpenAPI, {
	{{/equals}}
	{{/if}}
			method: '{{{method}}}',
			url: '{{{path}}}',
			{{#if parametersPath}}
			path: {
				{{#each parametersPath}}
				'{{{prop}}}': {{{name}}},
				{{/each}}
			},
			{{/if}}
			{{#if parametersCookie}}
			cookies: {
				{{#each parametersCookie}}
				'{{{prop}}}': {{{name}}},
				{{/each}}
			},
			{{/if}}
			{{#if parametersHeader}}
			headers: {
				{{#each parametersHeader}}
				'{{{prop}}}': {{{name}}},
				{{/each}}
			},
			{{/if}}
			{{#if parametersQuery}}
			query: {
				{{#each parametersQuery}}
				'{{{prop}}}': {{{name}}},
				{{/each}}
			},
			{{/if}}
			{{#if parametersForm}}
			formData: {
				{{#each parametersForm}}
				'{{{prop}}}': {{{name}}},
				{{/each}}
			},
			{{/if}}
			{{#if parametersBody}}
			{{#equals parametersBody.in 'formData'}}
			formData: {{{parametersBody.name}}},
			{{/equals}}
			{{#equals parametersBody.in 'body'}}
			body: {{{parametersBody.name}}},
			{{/equals}}
			{{#if parametersBody.mediaType}}
			mediaType: '{{{parametersBody.mediaType}}}',
			{{/if}}
			{{/if}}
			{{#if responseHeader}}
			responseHeader: '{{{responseHeader}}}',
			{{/if}}
			{{#if errors}}
			errors: {
				{{#each errors}}
				{{{code}}}: `{{{escapeDescription description}}}`,
				{{/each}}
			},
			{{/if}}
		});
	}

	{{/each}}
}
